#!/usr/bin/env python

import wx

class Printout(wx.Printout):
    '''Printout class
    
    mm = (pixels * 25.4) / dpi
    pixels = (mm * dpi) / 25.4
    
    WARNING!!!
    Using wxPython version 2.8 could not print without prompt.
    
    @author Julot <andy.julot@gmail.com>
    @since Sunday, January 29, 2012. 01:21 PM'''
    
    _numPages = 0
    
    def HasPage(self, page):
        return page <= self._numPages
    
    def GetPageInfo(self):
        return (1, self._numPages, 1, self._numPages)
    
    def mmToPixel(self, value):
        '''Convert value from millimeter to pixel.
        
        @param integer value in millimeter'''
        
        return (value * self.GetPPIPrinter()[0]) / 25.4
    
    def pixelToMm(self, value):
        '''Convert value from pixel to millimeter.
        
        @param integer value in pixel'''
        
        return (value * 25.4) / self.GetPPIPrinter()[0]
    
    def pointToPixel(self, value):
        '''Convert value from point to pixel.
        
        @param integer value in point'''
        
        return (value * self.GetPPIPrinter()[0]) / 72
    
    def pixelToPoint(self, value):
        '''Convert value from pixel to point.
        
        @param integer value in pixel'''
        
        return (value * 72) / self.GetPPIPrinter()[0]
    